package others;

import org.jsoup.internal.StringUtil;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

public class ParseContent2 {

    public static void main(String[] args) throws Exception {
        try (BufferedReader fr = new BufferedReader(new FileReader("D:\\data\\govcg\\cghttxt.txt"))){
            String line;
            String id = "";
            StringBuilder contentBuilder = new StringBuilder();
            String je = "";
            String qx = "";
            System.out.println("id\tbudge\ttimes");
            while ((line = fr.readLine()) != null) {
                if (line.contains("----id:")) {
                    if (!je.isEmpty() && !qx.isEmpty()) {
                        System.out.println(id.replace("\r", "") + "\t" + je + "\t" + qx);
                    }
                    id = line.split(":")[1];
                    je = "";
                    qx = "";
                } else {
                    if (line.contains("合同金额：")) {
                        // 获取合同金额
                        je = line.split("：")[1].split("，")[0];
                    }
                    if (line.contains("履约期限：")) {
                        qx = line.replace("<p>","").replace("</p>","")
                                .replace("履约期限：","");
                    }
                }
            }
            System.out.println(id + "\t" + je + "\t" + qx);
        }
    }

}
